﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;
using System.Threading;

namespace Skyttespill
{
    public class Hinder : MovingObject 
    {
        private SkPanel panel;
        private float vy;
        private int width, height;
        private bool moving;
        
        public Hinder(SkPanel _panel, int x, int y, int width, int height, bool moving)
        {
            panel = _panel;

            // Retning og størrelse på bevegende hinder
            this.x = x;
            this.y = y;
            this.width = width;
            this.height = height;
            this.moving = moving;
            vy = 1;
        }

        public int Height
        {
            get {return height;}
            //set { height = value; }
        }
        public int Width
        {
            get { return width; }
        }

        public bool Moving
        {
            get { return moving; }
        }

        // Bevegelse av Hinder i løkke
        public override void Move()
        {
            while (Active)
            {
                y -= vy;
                Size panelSize = panel.ClientRectangle.Size;
                if (y < 0)
                {
                    vy = -vy;
                }
                if (y + height >= panelSize.Height)
                {
                    vy = -vy;
                }
                
                Thread.Sleep(17);
            }
        }
            
        public override void tegn(Graphics g)
        {
            g.DrawImage(panel.vegg, x, y, width, height);
        }
    }
    
}


